<?php

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use app\widgets\Alert;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>

<div class="wrap theme2">
<?php
	if(isset(yii::$app->user->identity)){
		$name = isset(yii::$app->user->identity->profile->name) ? Yii::$app->user->identity->profile->name : Yii::$app->user->identity->username;
	}else{
		$name = '';
	}
?>
    <?php
 	//$username = isset(Yii::$app->user->identity->profile->name) ? Yii::$app->user->identity->profile->name :  Yii::$app->user->identity->username;
    NavBar::begin([
        'brandLabel' => '<i class="fa fa-anchor"></i> ',
        'brandUrl' => '#',//Yii::$app->homeUrl, // /product/product
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
			'style' => 'z-index:99',
        ],
    ]);
    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'items' => [

			Yii::$app->user->can('finance_index') ?
            ['label' => Yii::t("app.finance", "Finances"), 'url' => ['/finance/finance/index'],
             'options'=>['class'=>in_array(yii::$app->controller->id,['finance']) ? "active" : "" ] 
            ] : '',

			Yii::$app->user->can('order_index') ?
            ['label' => '订单管理', 'url' => ['/order/order/list'],
             'options'=>['class'=>in_array(yii::$app->controller->id,['order']) ? "active" : "" ] 
            ] : '',
			//!Yii::$app->user->isGuest && Yii::$app->userp\ ?statusstatus
			Yii::$app->user->can('product_index') ?
            ['label' => '团队管理', 'url' => ['/product/product'],
             'options'=>['class'=>in_array(yii::$app->controller->id,['product']) ? "active" : "" ] 
            ] : '',
			Yii::$app->user->can('statistic_index') ?
            ['label' => '统计管理', 'url' => ['/product/statistic/lines'],
             'options'=>['class'=>in_array(yii::$app->controller->id,['statistic']) ? "active" : "" ] 
            ] : '',
            
			Yii::$app->user->can('supplier_index') ?
            ['label' => '供应商管理', 'url' => ['/supplier/index'], 
             'options'=>['class'=>yii::$app->controller->id == "supplier" ? "active" : "" ] 
            ] : '',
			Yii::$app->user->can('cruise_index') ?
            ['label' => '邮轮管理', 'url' => ['/cruise/cruise/index'], 
             'options'=>['class'=>in_array(yii::$app->controller->id,['cruise','room','restaurant', 'recreation','service']) ? "active" : "" ] 
            ] : '' ,

			Yii::$app->user->can('user_index') ?
            ['label' => '账号管理', 'url' => ['/user/admin/index']] : '',

            Yii::$app->user->isGuest ? (['label' => '登录', 'url' => ['/user/login']] ) : 
				[	
					'label' => $name,
					'items' => [
                		
						[ 'label' => '修改密码',  'url' => '/site/update-password' ],
                        [ 'label' => '退出登录',  'url' => '/site/logout' ],
					],
				]

              
                //'<li>'
                //. Html::beginForm(['/user/logout'], 'post')
				//. Html::submitButton(
				//	'Logout (' . $name . ')',
				//	['class' => 'btn btn-link logout']
				//)
                //. Html::endForm()
                //. '</li>'
            
        ],
    ]);
    NavBar::end();
    ?>

    <div class="container">
        <!-- ?= Breadcrumbs::widget([
            'links' => i/sset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ? -->
        <div class="panel">
            <div class="panel-body">
            <?= Alert::widget() ?>
            <?= $content ?>
            </div>
        </div>
    </div>
</div>

<footer class="footer hidden-print">
    <div class="container">
        <p class="pull-left">&copy; My Company <?= date('Y') ?></p>

        <p class="pull-right">技术支持 - <b>北京瀚汶科技有限公司</b></p>
    </div>
</footer>

<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
